﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WMM.Tapioca.Linkbase;
using System.Xml.Linq;

namespace WMM.Tapioca.Formula
{
    /// <summary>
    /// General variables are used for intermediate expression results and other kinds of processing,
    /// such as function registry use, lookup table use, and more complex types of DTS linkbase tree traversal.
    /// </summary>
    public class GeneralVariable : Variable
    {
        private string select;

        /// <returns>The XPath expression implied by a general variable is the content of the @select attribute
        /// The context node for evaluation of the XPath expression is the <xbrli:xbrl> element of the input XBRL instance. </returns>
        public string Select
        {
            get { return select; }
            set { select = value; }
        }

        public GeneralVariable() { }

        /// <summary>
        /// Constructor.
        /// </summary>
        public GeneralVariable(Resource resource)
            : base(resource)
        {
            foreach (XAttribute attr in resource.ResourceXElement.Attributes())
            {
                if (attr.Name.LocalName.Equals("select"))
                {
                    select = attr.Value;
                }                
            }
        }

    }
}
